﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using QuanLyCongDan.DTO;

namespace QuanLyCongDan.GUI
{
    public partial class frmDanhsachDonVi : DevExpress.XtraEditors.XtraForm
    {
        public frmDanhsachDonVi(bool IsLogined)
        {
            InitializeComponent();

            simpleButtonUpdate.Enabled = IsLogined;

            try
            {
                DataSet ds = DAL.DAL_DonVi.GetDonViTable();
                dataGridViewDonVi.DataSource = ds.Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void simpleButtonUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable dt = (DataTable)dataGridViewDonVi.DataSource;
                DAL.DAL_DonVi.UpdateDonViTable(dt.DataSet);
                MessageBox.Show("Hoàn tất");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}